import java.util.*;

class Main {

	static <T> List<T> distinct(List<T> list) {
		List<T> uniqueList = new ArrayList<T>();
		for (int i = 0; i < list.size(); i++) {
			T e = list.get(i);
			if (!uniqueList.contains(e)) {
				uniqueList.add(e);
			}
		}
		return uniqueList;
	}
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入字符串的数量(不要超过8)：");
		int nStr = scanner.nextInt();
		System.out.println("请输入各个字符串，用空格分隔：");
		ArrayList<String> strList = new ArrayList<String>();
		for (int i = 0; i < nStr; i++) {
			String str = scanner.next();
			strList.add(str);
		}
		List<String> uniqueStrList = distinct(strList);
		System.out.println("去重之后：");
		for (int i = 0; i < uniqueStrList.size(); i++) {
			System.out.println(uniqueStrList.get(i));			
		}
		
		System.out.println("请输入整数的数量(不要超过8)：");
		int nInt = scanner.nextInt();
		System.out.println("请输入各个整数，用空格分隔：");
		ArrayList<Integer> intList = new ArrayList<Integer>();
		for (int i = 0; i < nInt; i++) {
			int x = scanner.nextInt();
			intList.add(x);
		}
		List<Integer> uniqueIntList = distinct(intList);
		System.out.println("去重之后：");
		for (int i = 0; i < uniqueIntList.size(); i++) {
			System.out.println(uniqueIntList.get(i));			
		}
	}
}
